// 1. 导入所需模块
import Vue from 'vue'
import VueRouter from 'vue-router'

// 2. 调用 Vue.use() 函数，将 VueRouter 安装为 Vue 的插件
Vue.use(VueRouter)

// 导入组件
import MyHome from '@/components/MyHome.vue'
import MyMovie from '@/components/MyMovie.vue'
import MyAbout from '@/components/MyAbout.vue'
import MyMusic from '@/components/MyMusic'

import AboutMe from '@/components/AboutMe'
import AboutYou from '@/components/AboutYou'
// 3. 创建路由的实例对象
const router = new VueRouter({
    routes: [
        // 一条一条的规则，都写到这里。规则，就是hash地址 和 组件的对应关系
        { path: '/home', component: MyHome },
        { path: '/movie/:id/:name', component: MyMovie },
        { path: '/music', component: MyMusic },
        {
            path: '/about', component: MyAbout,
            // path表示hash地址，如果是一级，/about。如果是二级，就不要加了
            // 会自动拼接成 /about/me/about/you
            children: [
                { path: 'me', component: AboutMe },
                { path: 'you', component: AboutYou }
            ]
        }
    ]
})

// 4. 导出路由的实例对象
export default router